
#ifndef SX_QDIRECTX_11_VIEWPORT_H
#define SX_QDIRECTX_11_VIEWPORT_H

#include <sxQViewport.h>
#include <sxDirectX_11_Context.h>

/* DirectX 11 Includes */
#include <windows.h>
#include <dxgi.h>
#include <d3d11.h>

using Sx::DirectX::Graphics::Contexts::DirectX_11_Context;

namespace Sx {
namespace QtInterface {

class QDirectX_11_Viewport : public QViewport {
	Q_OBJECT

public:
	QDirectX_11_Viewport(QWidget* parent, const std::shared_ptr<DirectX_11_Context>& context, unsigned int fps = 60u, Qt::WFlags flags = 0);
	QDirectX_11_Viewport(QWidget* parent, QDirectX_11_Viewport* share, unsigned int fps = 60u, Qt::WFlags flags = 0);
	virtual ~QDirectX_11_Viewport();

	/* QViewport Interface */
	bool initialize();
	void render() const;
	void reRender() const;
	void resize(int width, int height);

	/* Qt Events */
	void resizeEvent(QResizeEvent* e);
	void paintEvent(QPaintEvent* pEvent);

protected:
	/* OpenGL Context */
	std::shared_ptr<DirectX_11_Context> context;

	/* POINTER_OWNERSHIP: YES */
	IDXGISwapChain* swapChain;

	/* POINTER_OWNERSHIP: YES */
	ID3D11RenderTargetView* backbuffer;

	bool createBackBuffer(int width, int height);

	/* DirectX 11 Specific Viewport Sizing */
	static Util::ArrayList<QDirectX_11_Viewport*> viewports;
	static Util::ArrayList<D3D11_VIEWPORT> directXViewportSizes;
	static bool updateViewportSizes();
};

}

}

#endif
